package com.itheima.MOD4;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentManag {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        lo: while (true){
        System.out.println("----欢迎来到学生管理系统---");
        System.out.println("1 添加学生");
        System.out.println("2 删除学生");
        System.out.println("3 修改学生");
        System.out.println("4 查看所有学生");
        System.out.println("5  退出");
        System.out.println("请输入你的选择：");
        int a = sc.nextInt();
       switch (a){
            case 1:
                System.out.println("添加学生");
                addStudent(list);
                break;
            case 2:
                System.out.println("删除学生");

                break;
            case 3:
                System.out.println("修改学生");
                break;
            case 4:
                System.out.println("查看所有学生");
                queryStudents(list);
                break;
            case 5:
                System.out.println("溜了溜了");
                break lo;
                default:
                    System.out.println("您的输出有误");
                    break;

        }

    }
}

    public static void queryStudents(ArrayList<Student> list) {
        if(list.size()==0){
            System.out.println("没东西");
            return;
        }
        System.out.println("学号\t姓名\t年龄\t生日");
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getSid()+"\t"+stu.getName()+"\t"+stu.getAge()+"\t"+stu.getBirthday());
        }
    }

    //添加的学生方法
    public static void addStudent(ArrayList<Student> list) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的学号");
        String sid = sc.next();
        System.out.println("请输入姓名：");
        String name = sc.next();
        System.out.println("请输入年龄");
        int age = sc.nextInt();
        System.out.println("请输入生日");
        String birthday = sc.next();
        Student stu = new Student(sid,name,age,birthday);
        list.add(stu);
        System.out.println("添加成功");

    }
}
